package com.zzyl.serve.controller;

import com.zzyl.common.annotation.Log;
import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.core.page.TableDataInfo;
import com.zzyl.common.enums.BusinessType;
import com.zzyl.common.utils.poi.ExcelUtil;
import com.zzyl.serve.domain.NursingProjectPlan;
import com.zzyl.serve.service.INursingProjectPlanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 护理计划和项目关联Controller
 * 
 * @author mr.wu
 * @date 2025-05-16
 */
@RestController
@RequestMapping("/serve/projectPlan")
@Api(tags = "护理计划和项目关联管理")
public class NursingProjectPlanController extends BaseController
{
    @Autowired
    private INursingProjectPlanService nursingProjectPlanService;

    /**
     * 查询护理计划和项目关联列表
     */
    @PreAuthorize("@ss.hasPermi('serve:projectPlan:list')")
    @GetMapping("/list")
    @ApiOperation("查询护理计划和项目关联列表")
    public TableDataInfo list( @ApiParam(value = "护理计划和项目关联实体参数，用于筛选查询条件") NursingProjectPlan nursingProjectPlan)
    {
        startPage();
        List<NursingProjectPlan> list = nursingProjectPlanService.selectNursingProjectPlanList(nursingProjectPlan);
        return getDataTable(list);
    }

    /**
     * 导出护理计划和项目关联列表
     */
    @PreAuthorize("@ss.hasPermi('serve:projectPlan:export')")
    @Log(title = "护理计划和项目关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出护理计划和项目关联列表")
    public void export(@ApiParam(value = "HTTP 响应对象，用于输出 Excel 文件") HttpServletResponse response, @ApiParam(value = "护理计划和项目关联实体参数，用于筛选导出数据") NursingProjectPlan nursingProjectPlan)
    {
        List<NursingProjectPlan> list = nursingProjectPlanService.selectNursingProjectPlanList(nursingProjectPlan);
        ExcelUtil<NursingProjectPlan> util = new ExcelUtil<NursingProjectPlan>(NursingProjectPlan.class);
        util.exportExcel(response, list, "护理计划和项目关联数据");
    }

    /**
     * 获取护理计划和项目关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('serve:projectPlan:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取护理计划和项目关联详细信息")
    public AjaxResult getInfo(@ApiParam(value = "护理计划和项目关联唯一ID", required = true) @PathVariable("id") Long id)
    {
        return success(nursingProjectPlanService.selectNursingProjectPlanById(id));
    }

    /**
     * 新增护理计划和项目关联
     */
    @PreAuthorize("@ss.hasPermi('serve:projectPlan:add')")
    @Log(title = "护理计划和项目关联", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增护理计划和项目关联")
    public AjaxResult add(@ApiParam(value = "护理计划和项目关联实体，JSON 格式传入", required = true) @RequestBody NursingProjectPlan nursingProjectPlan)
    {
        return toAjax(nursingProjectPlanService.insertNursingProjectPlan(nursingProjectPlan));
    }

    /**
     * 修改护理计划和项目关联
     */
    @PreAuthorize("@ss.hasPermi('serve:projectPlan:edit')")
    @Log(title = "护理计划和项目关联", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改护理计划和项目关联")
    public AjaxResult edit(@ApiParam(value = "护理计划和项目关联实体，JSON 格式传入，需包含 ID", required = true) @RequestBody NursingProjectPlan nursingProjectPlan)
    {
        return toAjax(nursingProjectPlanService.updateNursingProjectPlan(nursingProjectPlan));
    }

    /**
     * 删除护理计划和项目关联
     */
    @PreAuthorize("@ss.hasPermi('serve:projectPlan:remove')")
    @Log(title = "护理计划和项目关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("删除护理计划和项目关联")
    public AjaxResult remove(@ApiParam(value = "多个护理计划和项目关联ID数组，逗号分隔", required = true) @PathVariable Long[] ids)
    {
        return toAjax(nursingProjectPlanService.deleteNursingProjectPlanByIds(ids));
    }
}
